{
    $("#nav_publink").click(function(){
        $( "#md_pub_1" ).dialog({
            resizable: false,
            height: 300,
            width: 400,
            modal: true
        });
    });
    $("#md_pub_prdlink").click(function(){
        $( "#md_pub_1" ).dialog("close");
        $( "#md_pub_prd1" ).dialog({
            resizable: false,
            height: 300,
            width: 400,
            modal: true,
            buttons: {
                "下一步": function() {
                    if($("#md_pub2_url").val() == '')
                    {
                        $( "#md_pub_prd1 span" ).html('商品地址不能为空');
                        return false;
                    }

                    $.post('/fetch/fetch_api.php','url='+encodeURIComponent($("#md_pub2_url").val()) , function(data){
                        eval("data="+data);
                        if(data.code!="A00006")
                        {
                            $( "#md_pub_prd1 span" ).html(data.msg);
                            return false;
                        }
                        else
                        {
                            $( "#md_pub_prd2 img" ).attr("src" , data.data.gd_small_pic);
                            $( "#md_pub_prd2 span:first" ).html(data.data.gd_title);
                            $( "#md_pub_prd2 span.price" ).html(data.data.gd_price);
                            
                            $( "#md_pub_prd1" ).dialog("close");
                            $( "#md_pub_prd2" ).dialog({
                                resizable: false,
                                modal: true,
                                height: 300,
                                width: 400,
                                buttons: {
                                    "发  布": function() {

                                        _post="content="+encodeURIComponent($( "#md_pub_prd2 textarea" ).val())
                                        +"&gd_pic="+encodeURIComponent(data.data.gd_small_pic)
                                        +"&gd_title="+encodeURIComponent(data.data.gd_title)
                                        +"&gd_url="+encodeURIComponent(data.data.gd_url)
                                        +"&gd_price="+data.data.gd_price;
                                        
                                        $.post('/riaapi/content/aj_publish.php',_post , function(data){
                                            eval("data="+data);
                                            if(data.code=="A00006")
                                            {
                                                $("#md_pb_rs").html('data.msg');
                                                $( "#md_pub_prd2" ).dialog("close");

                                                $( "#md_pub_rs" ).dialog({
                                                    resizable: false,
                                                    height: 300,
                                                    width: 400,
                                                    modal: true
                                                });
                                                setTimeout($( "#md_pub_rs" ).dialog("close") , 6000);
                                            }
                                        });
                                    }
                                }
                            });

                        }
                    })
                }
            }
        });
        
    });
    $("#md_pub_photolink").click(function(){
        $( "#md_pub_1" ).dialog("close");


        $( "#md_pub_img1" ).dialog({
            //resizable: false,
            //height: 140,
            modal: true,
            buttons: {
                "下一步": function() {

                    $.ajaxFileUpload({
                            url:'/image/upload.php',
                            secureuri:false,
                            fileElementId:'md_pub_img1_file',
                            dataType: 'json',
                            data:{name:'logan', id:'id'},
                            success: function (data, status)
                            {
                                if(data.code=='A00006')
                                {

                                    $( "#md_pub_img2 img" ).attr("src" , data.data.thumb);
                                    $( "#md_pub_img1" ).dialog("close");
                                    $( "#md_pub_img2" ).dialog({
                                        resizable: false,
                                            modal: true,
                                            height: 300,
                                            width: 400,
                                            buttons: {
                                            "发  布": function() {

                                                _post="content="+encodeURIComponent($( "#md_pub_img2 textarea" ).val())
                                                +"&pic_id="+data.data.pid;
                                                
                                                $.post('/riaapi/content/aj_publish.php',_post , function(data){
                                                    eval("data="+data);
                                                    if(data.code=="A00006")
                                                    {
                                                        $("#md_pb_rs").html('data.msg');
                                                        $( "#md_pub_img2" ).dialog("close");

                                                        $( "#md_pub_rs" ).dialog({
                                                            resizable: false,
                                                            height: 300,
                                                            width: 400,
                                                            modal: true
                                                        });
                                                        setTimeout($( "#md_pub_rs" ).dialog("close") , 6000);
                                                    }
                                                });
                                            }
                                        }
                                    });
                                }
                                else
                                {}
                            },
                    })
                }
            }
        });
        
    });
    
}
